package br.com.framework.client.web;

public class Entity {

	private boolean prependId;
	private String nameDisplay;
	private String nameEntity;
	private int sizeMin;
	private int sizeMax;
	private int maxlength;
	private String nameForm;
	private String nameSubmit;

	public Entity(boolean prependId, String nameDisplay, String nameEntity, int sizeMin, int sizeMax, int maxlength, String nameForm, String nameSubmit) {
		super();
		this.prependId = prependId;
		this.nameDisplay = nameDisplay;
		this.nameEntity = nameEntity;
		this.sizeMin = sizeMin;
		this.sizeMax = sizeMax;
		this.maxlength = maxlength;
		this.nameForm = nameForm;
		this.nameSubmit = nameSubmit;
	}

	public String getId() {
		return nameEntity;
	}

	public String getElementById() {
		return " document.getElementById('" + (prependId ? getNameForm() + ":" : "") + getId() + "')";
	}

	public String getIdSubmit() {
		return nameSubmit;
	}

	public String getElementByIdSubmit() {
		return " document.getElementById('" + (prependId ? getNameForm() + ":" : "") + getIdSubmit() + "')";
	}

	public String getOnkeypress() {
		return "if (event.keyCode == 13){ " + getElementByIdSubmit() + ".click(); return false;}";
	}

	public String getNameDisplay() {
		return nameDisplay;
	}

	public int getMaxlength() {
		return maxlength;
	}

	public String getNameForm() {
		return nameForm;
	}

	public String getNameSubmit() {
		return nameSubmit;
	}

	public int getSizeMin() {
		return sizeMin;
	}

	public int getSizeMax() {
		return sizeMax;
	}

	public boolean isPrependId() {
		return prependId;
	}

	public String getNameEntity() {
		return nameEntity;
	}

}
